<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
	<title>KumbiaPHP web &amp; app Framework</title>
	<link rel="stylesheet" href="<?php echo PUBLIC_PATH ?>css/style.css" />
    <link rel="stylesheet" href="<?php echo PUBLIC_PATH ?>css/bienvenida.css" />
    <link rel="stylesheet" href="<?php echo PUBLIC_PATH ?>css/exception.css" />
</head>
<body>
	<div class="exception">
	<?php echo $content ?>
	<div class="exception_information">
<h2>Rastro</h2>
    <?php
    //var_dump($e->getTrace());
    foreach ($e->getTrace() as $trace): ?>
        <?php if (isset ( $trace ['file'] ) && !(strpos ( $trace ['file'], APP_PATH) ===false) && !(strpos ( $trace ['file'], 'index.php'))): ?>
            <p><strong><?php echo htmlspecialchars($trace['file'], ENT_NOQUOTES, 'UTF-8') . "(" . $trace ['line'] . ")" ?></strong></p>
            <p>La excepción se ha generado en el archivo <span class="italic"><?php echo $trace['file'] ?></span> en la línea: <span class="italic"><?php echo $trace['line'] ?></span>:</p>

            <ul class="exception_trace">
                <?php
                    $lines = file ( $trace ['file'] );
                    $start = ($trace ['line'] - 4) < 0 ? 0 : $trace ['line'] - 4;
                    $end = ($trace ['line'] + 2) > count ( $lines ) - 1 ? count ( $lines ) - 1 : $trace ['line'] + 2;
                ?>

                <?php for($i = $start; $i <= $end; $i ++): ?>
                    <li <?php if ($i == $trace ['line'] - 1): ?> class="exception_highlight" <?php endif; ?>">
                        <strong><?php echo ($i + 1) ?></strong> <?php echo htmlspecialchars($lines [$i], ENT_NOQUOTES, 'UTF-8') ?>

                    </li>
                <?php endfor; ?>
            </ul>

            <br />
        <?php endif; ?>
    <?php endforeach; ?>

    <table><thead><tr>
    <th>#</th><th>Fichero (línea)</th><th>Función</th>
    </tr></thead>
    <tbody>
    <?php $lines = explode("\n",$e->getTraceAsString());
	 $files = get_included_files();
	 foreach ($lines as $line){
	 $line = explode(" ",$line);?>
	 <tr><td><?php echo $line[0] ?></td><td><?php echo $line[1] ?></td><td><?php if(isset($line[2])) echo $line[2] ?></td></tr>
	 <?php } ?>
	</tbody>
    </table>
</div>

<div class="exception_information">
<h2>Información Adicional</h2>
    <strong>En producción:</strong> <?php echo PRODUCTION ?  'Sí' : 'No' ?><br />
    <strong>Ubicación actual:</strong> <?php echo $route ?><br />
    <strong>Librerías:</strong> <?php //echo $boot['modules']['libs'] ?><br />
    <strong>Server: </strong> <?php echo $_SERVER['SERVER_SOFTWARE'] ?><br />
    <strong>IP Server: </strong> <?php echo $_SERVER['SERVER_ADDR'] ?><br />
    <strong>IP Visitante: </strong> <?php echo $_SERVER['REMOTE_ADDR'] ?><br />
</div>

<table><thead><tr>
<th><h3><?php echo round((microtime(1)-START_TIME),4),' seg.'?></h3>Tiempo</th><th><h3><?php echo number_format(memory_get_usage() / 1048576, 2),' MB';?></h3>Memoria Usada</th><th><h3><?php echo count($files) ?> ficheros</h3>Includes</th>
</tr>
<tr>
<th><h3><?php echo ini_get('max_execution_time'),' seg.'?></h3>Tiempo Máximo PHP</th><th><h3><?php echo ini_get('memory_limit');?></h3>Memoria PHP</th><th><h3><?php echo PHP_VERSION?></h3>Versión PHP</th>
</tr>
</thead>
</table>
<?php //var_dump($files); ?>

</div>
<?php include APP_PATH.'views/_shared/partials/kumbia/footer.phtml'?>
</body>
</html>
